package com.xsqf.jt808.common.vo;

import lombok.Data;

@Data
public class ResultVo {

    public static final int CODE_SUCCESS = 1;
    public static final int CODE_FAIL = 0;
    public static final int CODE_NOT_LOGIN = -1;
    public static final String MSG_SUCCESS = "ok";
    public static final String MSG_FAIL = "fail";
    public static final String MSG_NOT_LOGIN = "need login";

    // 编码: 1, 0, -1, -2, -3等状态
    int code;
    // 返回数据说明
    String msg;
    // 异常信息,一般用于给开发人员检查问题
    String errorMsg;
    // 返回数据体
    Object content;

    public ResultVo() {

    }

    public ResultVo(Boolean b) {
        if (!b) {
            this.code = CODE_FAIL;
            this.msg = MSG_FAIL;
        } else {
            this.code = CODE_SUCCESS;
            this.msg = MSG_SUCCESS;
        }
    }

    public ResultVo(Object content) {
        super();
        this.code = CODE_SUCCESS;
        this.msg = MSG_SUCCESS;
        this.content = content;
    }

    public ResultVo(Boolean b, Object content) {
        if (!b) {
            this.code = CODE_FAIL;
            this.msg = MSG_FAIL;
        } else {
            this.code = CODE_SUCCESS;
            this.msg = MSG_SUCCESS;
        }
        this.content = content;
    }

    public ResultVo(int code, String msg) {
        super();
        this.code = code;
        this.msg = msg;
    }

    public ResultVo(int code, String msg, String errorMsg) {
        super();
        this.code = code;
        this.msg = msg;
        this.errorMsg = errorMsg;
    }

    public ResultVo(int code, String msg, Object content) {
        super();
        this.code = code;
        this.msg = msg;
        this.content = content;
    }

    public ResultVo(int code, String msg, String errorMsg, Object content) {
        super();
        this.code = code;
        this.msg = msg;
        this.errorMsg = errorMsg;
        this.content = content;
    }

}
